//
//  ViewController.m
//  jiejie
//
//  Created by youyoumacmini3 on 17/3/22.
//  Copyright © 2017年 youyoumacmini3. All rights reserved.
//

#import "ViewController.h"

#import "Masonry.h"

@interface ViewController ()
{
    BOOL isFirst;
}

@property (weak, nonatomic) IBOutlet UIButton *ruleBtn;
@property (weak, nonatomic) IBOutlet UITextView *ruleTextView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
  
    
    
    [self addUI];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    //[self qidongye];

}

- (void)qidongye{
    if (isFirst == NO) {
        UIWindow *window = [UIApplication sharedApplication].keyWindow;
        // 添加启动页的图片
        UIImageView *welcomeImage = [[UIImageView alloc]initWithFrame:window.bounds];
        welcomeImage.image = [UIImage imageNamed:@"EFFF329035EBFD66944419B0278F0EBF"];
        [window addSubview:welcomeImage];
        [window bringSubviewToFront:welcomeImage]; // 把背景图放在最上层
        welcomeImage.alpha = 0.99;//这里alpha的值和下面alpha的值不能设置为相同的，否则动画相当于瞬间执行完，启动页之后动画瞬间消失。这里alpha设为0.99，动画就不会有一闪而过的效果，而是一种类似于静态背景的效果。设为0，动画就相当于是淡入的效果了。
        
        // UIViewAnimationOptionCurveEaseOut
        [UIView animateKeyframesWithDuration:2.5 delay:1.5 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
            welcomeImage.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5);
            //        welcomeImage.transform = CGAffineTransformMakeScale(1.3, 1.3);
            welcomeImage.alpha = 0.0;
        } completion:^(BOOL finished) {
            [welcomeImage removeFromSuperview];
        }];
        isFirst = YES;
    }
}

- (void)addUI{
   // self.ruleTextView.frame = CGRectMake(40, 254, self.ruleTextView.frame.size.width, 0);
    
    self.ruleTextView.alpha = 0;

    
}
- (IBAction)click1:(UIButton*)button {

   static int a = 0;
    a ++;
    
    NSLog(@"%d",a);
    
    if (a%2 == 0) {
        
        [UIView animateWithDuration:1.0 animations:^{
           self.ruleTextView.alpha = 0;
        }];
        
        
    }else{
        
        [UIView animateWithDuration:1.0 animations:^{
     self.ruleTextView.alpha = 1;
        }];
        
    }
    
    
}
- (IBAction)agree:(id)sender {
    [self performSegueWithIdentifier:@"one" sender:nil];
}


- (IBAction)dissAgree:(id)sender {
    [self performSegueWithIdentifier:@"one" sender:nil];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
